<script>
//---进度条
$("#restoreButton").click(function() {
    var bValid = true;
    var qos_policy = $("#restore_nav option:selected").val();
    var qos_maxbw = $("#maxbw").val();

    if (qos_policy == '1') {
        qos_maxbw = '-1';
    } else {
        bValid = bValid && checkRegexp($(".maxbw"), /^[0-9]+$/, "最大带宽只能为整数.");
    }


    var val0 = {
        maxbw_default: $("#maxbw_default").val(),
        qos_maxbw: qos_maxbw,
        qos_policy: qos_policy,
    };
    if (bValid) {
        $.ajax({
            url: '/recover_qos',
            type: "POST",
            dataType: "json",
            data: val0,
            success: function(data) {
                $(".error_tip").text("设置完成").css({
                    "display": "block",
                    "color": '#000'
                });

            }
        });
    }
});

function recover_change() {
    var qos_policy = $("#restore_nav option:selected").val();
    if (qos_policy == '1') {
        $("#recover_maxbw1").hide();
        $("#recover_maxbw2").show();
    } else {
        $("#recover_maxbw1").show();
        $("#recover_maxbw2").hide();
    }
}


function dochange(text,value) {
    if(value == '2') {
        alert(2);
        $("#recover_maxbw1").hide();
        $("#recover_maxbw2").show();
    } else {
        $("#recover_maxbw1").hide();
        $("#recover_maxbw2").show();
    }
}
$('#recover_style').rqDropDown({
    "onchange":"dochange",
    "datatype": "local",
    "source": [
        ['1', '恢复数据QoS'],
        ['2', '优先恢复数据']
    ]
});
</script>
<div class="panel panel-f-style">
    <div class="panel-body">
        <div class="title-tag">
            <h3>数据恢复</h3>
            <p>数据恢复</p>
        </div>

        <div style="margin:20px 0 40px 0; padding: 20px;border-bottom: #eee solid 1px;">
            <input id="recover_style" readonly="readonly" class="rounded_dropdown" value='恢复数据Qos' realvalue="1" />
        </div>

        <div id="recover_maxbw1" style="margin:20px 0 40px 0; padding: 20px;">
            <p>有限数据占用较大带宽，可能会影响业务</p>
            <div class="error_tip"></div>
            {% if policy == '0'%}
            <span>设置最大带宽</span>
            <input type="text" placeholder="数值为整数" id="maxbw" class="maxbw" value="{{maxbw}}"><span class="restore_unit">Bps</span> {% elif policy == '1'%}
            <span>设置最大带宽</span>
            <input type="text" placeholder="数值为整数" id="maxbw" class="maxbw"><span class="restore_unit">Bps</span> {% endif %}
        </div>

        <div id="recover_maxbw2" style=" margin:20px 0 40px 0; padding: 20px;display: none;">
             <p>有限数据占用较大带宽，可能会影响业务</p>
                    <div class="error_tip"></div>
                    <span>设置最大带宽</span><span id="maxbw_default" style="padding:0px 30px;">-1</span><span class="restore_unit">Bps</span>
        </div>

        <div style="margin:20px 0 40px 0; padding: 20px;">
            <button type="button" class="btn btn-blue" id="restoreButton">[['label ok'|translate]]</button>
        </div>
    </div>
</div>
<!-- 
<div class="panel panel-default">
    <div class="panel-body" style="background-color:#fbfbfb">
        <div id="restore_menu">
            <p style="font-size:25px;padding:20px 0px;">数据恢复</p>
            {% if msg %}
            <div class="error_tip" style="display:block">{{msg}}</div>
            {% else %}
            <select id="restore_nav" onchange="recover_change()">
                {% if policy == '0'%}
                <option id="re_op1" value='0' selected=true><a href="#" class="selected">恢复数据QoS</a></option>
                <option id="re_op2" value='1'><a href="#" class="">优先恢复数据</a></option>
                {% elif policy == '1'%}
                <option id="re_op1" value="0"><a href="#" class="">恢复数据Qos</a></option>
                <option id="re_op2" value="1" selected=true><a href="#" class="selected">优先恢复数据</a></option>
                {% endif %}
            </select>
            <br/>
            <div id="menu_con">
                <div class="tag restore_set" id="recover_maxbw1" style="display:block">
                    <p>有限数据占用较大带宽，可能会影响业务</p>
                    <div class="error_tip"></div>
                    {% if policy == '0'%}
                    <span>设置最大带宽</span>
                    <input placeholder="数值为整数" id="maxbw" class="maxbw" value="{{maxbw}}"><span class="restore_unit">Bps</span> {% elif policy == '1'%}
                    <span>设置最大带宽</span>
                    <input placeholder="数值为整数" id="maxbw" class="maxbw"><span class="restore_unit">Bps</span> {% endif %}
                </div>
                <div class="tag restore_set" style="display:none" id="recover_maxbw2">
                    <p>有限数据占用较大带宽，可能会影响业务</p>
                    <div class="error_tip"></div>
                    <span>设置最大带宽</span><span id="maxbw_default" style="padding:0px 30px;">-1</span><span class="restore_unit">Bps</span>
                </div>
                <input type="button" value="[['label ok'|translate]]" class="button button_gray restrue_sub" id="restoreButton" />
            </div>
            {% endif %}
        </div>
    </div>
</div> -->
